<?php
    if( !function_exists( "getFlashBaseDir" ) ){
		function getFlashBaseDir( $flash_id = '',$intStoreId )
		{
			$dir_base_4_navigator = '';
		   
			if( $flash_id > 0 ){
				if( file_exists( Mage::getBaseDir('media')."/slideshow/items/{$flash_id}/{$intStoreId}/settings.xml" ) ){
					$dir_base_4_navigator = Mage::getBaseDir('media')."/slideshow/items/{$flash_id}/{$intStoreId}";
				}else if( file_exists( Mage::getBaseDir('media')."/slideshow/items/{$flash_id}/settings.xml" ) ){
					$dir_base_4_navigator = Mage::getBaseDir('media')."/slideshow/items/{$flash_id}";
				}else{
					$dir_base_4_navigator = Mage::getBaseDir('media')."/slideshow/items/default";
				}
			}else{
				$dir_base_4_navigator = Mage::getBaseDir('media')."/slideshow/items/default";
			}
			
			return $dir_base_4_navigator;
		}
    }
    
   
    $flash_id = $this->getData('id');
    $intStoreId = Mage::app()->getStore()->getId();   
    $jsBaseUrl = Mage::getBaseUrl('js');
    $mediaBaseUrl = Mage::getBaseUrl('media');
    $naviatory_base_dir = getFlashBaseDir( $flash_id,$intStoreId );
	
	$xml = simplexml_load_file( $naviatory_base_dir."/settings.xml" );
	$strBlockCode = '';
?>
<div class="home-main-navigater">
<div id="slider" class="slider_wrapper">
<?php	
	$image = 0;
    for($i=0;$i<count($xml->links->link);$i++):		
		if( !empty( $xml->links->link[$i]->background_image ) ):
			$image++;
			$image_url = stristr( $xml->links->link[$i]->background_image,'http://' ) ? $xml->links->link[$i]->background_image:eregi_replace( '\/index\.php\/?','', Mage::getBaseUrl('web') ) . $xml->links->link[$i]->background_image;
	?>
		<div class="contentdiv">
			<a href="<?php echo $xml->links->link[$i]->link_url;?>" title="<?php echo $this->__("Image navigator");?>"><img src="<?php echo $image_url;?>" border="0"></a>
		</div>
		<?php endif;?>	
	<?php endfor; ?>
</div>
<div id="paginate-slider" class="pagination"></div>
</div>
<?php if( $image > 1 ):?>
<script type="text/javascript">
featuredcontentslider.init({
	id: "slider",  //id of main slider DIV
	contentsource: ["inline", ""],  //Valid values: ["inline", ""] or ["ajax", "path_to_file"]
	toc: "#increment",  //Valid values: "#increment", "markup", ["label1", "label2", etc]
	nextprev: ["", ""],  //labels for "prev" and "next" links. Set to "" to hide.
	revealtype: "click", //Behavior of pagination links to reveal the slides: "click" or "mouseover"
	enablefade: [true, 0.2],  //[true/false, fadedegree]
	autorotate: [true, 3000],  //[true/false, pausetime]
	onChange: function(previndex, curindex){  //event handler fired whenever script changes slide
		//previndex holds index of last slide viewed b4 current (1=1st slide, 2nd=2nd etc)
		//curindex holds index of currently shown slide (1=1st slide, 2nd=2nd etc)		
	}
})
</script>
<?php endif;?>

